home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1780 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  49 lines

  1. Path: colt-74.slip.uiuc.edu!user
  2. From: bwood@uiuc.edu (Brett Wood)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Help with simple code
  5. Date: Tue, 16 Jan 1996 15:49:15 -0600
  6. Organization: University of Illinois
  7. Message-ID: <bwood-1601961549150001@colt-74.slip.uiuc.edu>
  8. References: <4dbak5$oij@ionews.io.org> <tcpnntpd.16.1.16.0.51.40.2781597121.342670@the-fix.sos.on.ca>
  9. NNTP-Posting-Host: colt-74.slip.uiuc.edu
  10.  
  11. In article <tcpnntpd.16.1.16.0.51.40.2781597121.342670@the-fix.sos.on.ca>,
  12. <verneb@the-fix.sos.on.ca> wrote:
  13.  
  14. > I >Can anyone tell me what's wrong with this piece of code? I lifted it
  15. > I >straight from a textbook.
  16. > I >
  17. > I >Here's the code:
  18. > I >
  19. > I >/* Calculating compound interest */
  20. > I >..h>
  21. > I >..h>
  22. > I >
  23. > I >main()
  24. > I >{
  25. > I >     int year;
  26. > I >     double amount, principal = 1000, rate = 0.5;
  27. > I >
  28. > I >     printf("%4s%21s\n", "Year", "Amount on deposit");
  29. > I >
  30. > I >     for (year = 1; year <= 10; year++) {
  31. > I >             amount = principal * pow(1.0 + rate, year);
  32. > I >             printf("%4d%21.2f\n", year, amount);
  33. > I >     }
  34. > I >
  35. > I >     return 0;
  36. > I >}
  37. > I >______________________________________________________________
  38. > I >
  39. > I >and here's the error:
  40. > I >
  41. > I >In function `main':
  42. > I >undefined reference to `pow'
  43. > I >
  44. > I >I don't understand. `pow' is a function, not a variable?
  45. > I >Can anyone tell me what's wrong?
  46. > I >
  47.  
  48. Did you #include <math.h> ??
  49.